class Position(object):

    def __init__(self, symbol, price, side, amount):
        self.symbol = symbol
        self.cost = price
        self.side = side
        self.amount = amount
        self.cloesdPL = 0
        self.PL = 0;

class Positions(object):

    #---Open File, fill to Positions---
    def __init__(self, positionFileName):
        self.positions = {}
        file = open(positionFileName, 'r')
        countLine = 0;
        while True:
            s = file.readline()
            countLine = countLine + 1
            if s == '':
                break
            if countLine == 1:
                continue

            ss = s.split(',')
            symbol = ss[0]
            sFlag = ss[2]
            qty = float(ss[3])
            price = float(ss[8])
            if sFlag == "卖":
                sFlag = "Short"
            else:
                sFlag = "Long"

            #---Set to Directory---
            position = Position(symbol,price,sFlag,qty)
            self.positions[symbol + "_" + sFlag] = position
        file.close()

    def Positions(self):
        return self.positions